home *** CD-ROM | disk | FTP | other *** search
/ Network CD 2 / Network CD - Volume 2.iso / programs / internet / tcp / amitcp / amitcp-src-22.lha / AmiTCP-2.2 / src / appl / napsaterm / beep.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-07  |  1.4 KB  |  54 lines

  1. RCS_ID_C "$Id: beep.c,v 1.5 1993/07/12 22:50:24 ppessi Exp $";
  2. /* Most of this was stolen from the "beep" program from the Manx 3.6a
  3.  * distribution.
  4.  * 
  5.  * $Author: ppessi $ $Revision: 1.5 $ $Date: 1993/07/12 22:50:24 $
  6. */
  7.  
  8. #include "amiga.h"
  9. #include "display.h"
  10.  
  11. #include <devices/audio.h>
  12.  
  13. UBYTE allocmap[] = { 1, 8, 2, 4 };
  14. UBYTE bwave[] = { 69, 116, 126, 96, 36, 220, 160, 130, 140, 0 };
  15.  
  16. void
  17. audiobell()
  18. {
  19.     struct MsgPort *mp = NULL;
  20.     struct IOAudio *ar = NULL;
  21.     UBYTE *wave = NULL;
  22.  
  23.     if(!(mp = CreateMsgPort()) ||
  24.        !(wave = (UBYTE *)AllocMem(10, MEMF_CHIP)) ||
  25.        !(ar = (struct IOAudio *)CreateIORequest(mp, sizeof(*ar)))) {
  26.         dsinvert(VISUAL_BELL);
  27.     goto CleanReturn;
  28.     }
  29.     strcpy(wave, bwave);
  30.     ar->ioa_Request.io_Message.mn_Node.ln_Pri = 20;
  31.     ar->ioa_Data = allocmap;
  32.     ar->ioa_Length = sizeof(allocmap);
  33.     if(OpenDevice(AUDIONAME, 0, (struct IORequest *)ar, 0) == 0) {
  34.         ar->ioa_Request.io_Command = CMD_WRITE;
  35.     ar->ioa_Request.io_Flags = ADIOF_PERVOL;
  36.     ar->ioa_Data = wave;
  37.         ar->ioa_Length = 10;
  38.     ar->ioa_Period = 421;
  39.         ar->ioa_Volume = 64;
  40.     ar->ioa_Cycles = 100;
  41.  
  42.     BeginIO((struct IORequest *)ar);
  43.     WaitIO((struct IORequest *)ar);
  44.     CloseDevice((struct IORequest *)ar);
  45.     } else dsinvert(VISUAL_BELL);
  46.  
  47.  CleanReturn:
  48.     if (wave) FreeMem(wave, 10);
  49.     if (ar) DeleteIORequest((struct IORequest *)ar);
  50.     if (mp) DeleteMsgPort(mp);
  51. }
  52.  
  53.  
  54.